package com.demo;



import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.demo.util.HttpClientUtil;
import com.demo.util.HttpClientUtil2;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;


@SpringBootTest
public class ApiDemo {

    @Test
    public void test(){
        String s = HttpClientUtil.doGet("http://127.0.0.1:8081/BJGR/api/demo/demo");
        System.out.println(s);
    }

    @Test
    public void test2(){
        String s = HttpClientUtil.doGet("http://127.0.0.1:8081/BJGR/api/coordinate/selectDemo");
        System.out.println(s);
    }

    @Test
    public void test3(){
        String data = "{\n" +
                "    \"buildingid\":\"31323\",\n" +
                "    \"ordinate\":\"1\",\n" +
                "    \"abscissa\":\"2\"\n" +
                "}";
        String s = HttpClientUtil.doPost("http://127.0.0.1:8081/BJGR/api/coordinate/addDemo" , data);
        System.out.println(s);
    }
    @Test

    public void test4(){
        String data = "[\n" +
                "    {\n" +
                "        \"buildingid\":\"33\",\n" +
                "        \"ordinate\":\"1\",\n" +
                "        \"abscissa\":\"2\"\n" +
                "    },\n" +
                "    {\n" +
                "        \"buildingid\":\"55\",\n" +
                "        \"ordinate\":\"1\",\n" +
                "        \"abscissa\":\"2\"\n" +
                "    }\n" +
                "]";
        String s = HttpClientUtil.doPost("http://127.0.0.1:8081/BJGR/api/coordinate/addListDemo" , data);
        System.out.println(s);
    }

    @Test
    public void test5(){
        String s = HttpClientUtil2.doGet("http://127.0.0.1:8081/BJGR/api/demo/demo" ,"UTF-8");
        System.out.println(s);
    }

    @Test
    public void test6(){
        String s = HttpClientUtil2.doGet("http://127.0.0.1:8081/BJGR/api/coordinate/selectDemo" , "UTF-8");
        System.out.println(s);
    }

    @Test
    public void test7(){
        String data = "{\n" +
                "    \"buildingid\":\"1223\",\n" +
                "    \"ordinate\":\"1\",\n" +
                "    \"abscissa\":\"21\"\n" +
                "}";
        JSONObject jsonObject =  JSON.parseObject(data);
        jsonObject.put("param", jsonObject);
        String s = HttpClientUtil2.doPost("http://127.0.0.1:8081/BJGR/api/coordinate/addDemo" , jsonObject);
        System.out.println(s);
    }



}
